/**
 * 文件功能：底图图层数据
 * 文件作者：我是𝒆𝒅.
 */
import { OSM } from "ol/source";
import { Tile as TileLayer, Vector as VectorLayer } from "ol/layer";
import gcj02Mecator from "./gcj02Mecator";
import XYZ from "ol/source/XYZ";

// 全部底图数据
export const allLayers = [];

// 开放道路底图
export const OSMLayer = new TileLayer({
  title: "underlayLayer", // 底图名称
  source: new OSM(), // 数据源
  zIndex: 0, // 图层层级0
});

// 谷歌地图
export const GoogleLayer = new TileLayer({
  title: "underlayLayer",
  source: new XYZ({
    projection: gcj02Mecator,
    url: "http://www.google.cn/maps/vt/pb=!1m4!1m3!1i{z}!2i{x}!3i{y}!2m3!1e0!2sm!3i345013117!3m8!2szh-CN!3scn!5e1105!12m4!1e68!2m2!1sset!2sRoadmap!4e0",
  }),
  zIndex: 0,
});

// 高德在线
export const GDMapOnline = new TileLayer({
  title: "underlayLayer",
  source: new XYZ({
    projection: gcj02Mecator,
    url: "http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}",
  }),
  zIndex: 0,
});

// 天地图道路
export const TMStreet = new TileLayer({
  title: "underlayLayer",
  source: new XYZ({
    url: "http://t4.tianditu.com/DataServer?T=vec_w&tk=36d7142ebe5f4c685473a4020305778e&x={x}&y={y}&l={z}",
  }),
  zIndex: 0,
});

// 天地图卫星
export const TMSatellite = new TileLayer({
  title: "underlayLayer",
  source: new XYZ({
    url: "http://t4.tianditu.com/DataServer?T=img_w&tk=1f2d661cc5d79c237ac9675626849e94&x={x}&y={y}&l={z}",
  }),
  zIndex: 0,
});

// 天地图标注
export const TMTitle = new TileLayer({
  title: "underlayLayerForTMTitle",
  source: new XYZ({
    url: "http://t3.tianditu.com/DataServer?T=cva_w&tk=1f2d661cc5d79c237ac9675626849e94&x={x}&y={y}&l={z}",
  }),
  zIndex: 0,
});

allLayers.push(
  OSMLayer,
  GoogleLayer,
  GDMapOnline,
  TMStreet,
  TMSatellite,
  TMTitle
); // 将底图数据添加到全部底图数据
